package com.mou.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mou.dto.ProductFavoritesDTO;
import com.mou.entity.ProductFavorites;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ProductFavoritesMapper extends BaseMapper<ProductFavorites> {


    @Select("select * from product_favorites where user_id = #{userId} and product_id = #{productId} and deleted = 0")
    ProductFavorites uniqueUserProductFavorites(ProductFavoritesDTO productFavoritesDTO);

    @Update("update product_favorites set deleted = 1 where user_id = #{userId} and product_id = #{productId}")
    void deleteFavorites(ProductFavoritesDTO productFavoritesDTO);

    @Select("select * from product_favorites where user_id = #{userId} and deleted = 0")
    List<ProductFavorites> getByUserId(Integer userId);
}
